package cn.kgc.controller;

import cn.kgc.bean.pojo.EqDevice;
import cn.kgc.bean.pojo.EqHazardDevice;
import cn.kgc.bean.vo.Result;
import cn.kgc.service.EqHazardDeviceService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @projectName: safetyMag
 * @package: cn.kgc.controller
 * @className: EqHazardDeviceController
 * @author: yindexin
 * @description: TODO
 * @date: 2023/5/2 0:53
 * @version: 1.0
 */
@RestController
@RequestMapping("eqHazardDevice")
public class EqHazardDeviceController {
    @Resource
    private EqHazardDeviceService eqHazardDeviceService;

    @RequestMapping("/getEqHazardDeviceAll/{pageFrom}/{pageSize}")
    private Result getEqHazardDeviceAll(@PathVariable Integer pageFrom,
                                        @PathVariable Integer pageSize){
        PageHelper.startPage(pageFrom, pageSize);
        List<EqHazardDevice> list = eqHazardDeviceService.getEqHazardDeviceAll();
        PageInfo pageInfo = new PageInfo(list);

        return Result.success(pageInfo);

    }

    @RequestMapping("/addEqHazardDeviceAll")
    private Result addEqHazardDeviceAll(@RequestBody EqHazardDevice eqHazardDevice){
        boolean flag = eqHazardDeviceService.addEqHazardDeviceAll(eqHazardDevice);
        if (flag) {
            return Result.success();
        }
        return Result.failure();
    }
    @RequestMapping("/deletEqHazardDeviceAllById/{id}")
    private Result deletEqHazardDeviceAllById(@PathVariable Integer id){
        boolean flag = eqHazardDeviceService.deletEqHazardDeviceAllById(id);
        if (flag) {
            return Result.success();
        }
        return Result.failure();
    }
    @RequestMapping("/UpdateEqHazardDeviceAll")
    private Result UpdateEqHazardDeviceAll(@RequestBody EqHazardDevice eqHazardDevice){
        boolean flag = eqHazardDeviceService.UpdateEqHazardDeviceAll(eqHazardDevice);
        if (flag) {
            return Result.success();
        }
        return Result.failure();
    }
}
